package com.qianfeng.zw.meilishuo.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.qianfeng.zw.meilishuo.R;
import com.qianfeng.zw.meilishuo.listener.OnItemClickLitener;
import com.qianfeng.zw.meilishuo.bean.TwitterGoods;
import com.qianfeng.zw.meilishuo.utils.ImageLoaderHelper;
import com.qianfeng.zw.meilishuo.vh.AppViewHolder;

import java.util.List;


/**
 * @作 用:
 * @创 建 人: zhangwei
 * @日 期: 15/3/29 14:40
 * @修 改 人:
 * @日 期:
 */

public class FashionGoodsAdapter extends RecyclerView.Adapter<FashionGoodsAdapter.FashStagViewHolder> implements OnItemClickLitener {
    private List<TwitterGoods> list;
    //ImageLoader配置
    private DisplayImageOptions options;

    public FashionGoodsAdapter(List<TwitterGoods> list) {
        this.list = list;
        options = ImageLoaderHelper.getInstance().getDefaultDisplayImageOptions();
    }

    public class FashStagViewHolder extends AppViewHolder {
        //        @ViewById(R.id.fash_goods_img)
        public ImageView img;
        //        @ViewById(R.id.fash_goods_remark)
        public TextView remarkTv;
        //        @ViewById(R.id.fash_goods_price)
        public TextView priceTv;
        //        @ViewById(R.id.fash_goods_like)
        public TextView likeTv;

        public FashStagViewHolder(View itemView, OnItemClickLitener onItemClickLitener) {
            super(itemView, onItemClickLitener);
            img = (ImageView) itemView.findViewById(R.id.fash_goods_img);
            remarkTv = (TextView) itemView.findViewById(R.id.fash_goods_remark);
            priceTv = (TextView) itemView.findViewById(R.id.fash_goods_price);
            likeTv = (TextView) itemView.findViewById(R.id.fash_goods_like);
        }
    }

    @Override
    public FashStagViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_home_fashstag_layout, parent, false);
        FashStagViewHolder vh = new FashStagViewHolder(itemView, this);
        return vh;
    }

    @Override
    public void onBindViewHolder(FashStagViewHolder holder, int position) {
        TwitterGoods goods = list.get(position);
        ImageLoader.getInstance().displayImage(goods.getPicUrl(), holder.img, options);
        holder.remarkTv.setText(goods.getRemark());
        holder.priceTv.setText(goods.getTitle().trim());
        holder.likeTv.setText(goods.getCountLike());
    }

    @Override
    public int getItemCount() {
        return list != null && !list.isEmpty() ? list.size() : 0;
    }

    @Override
    public void onItemClick(View view, int position) {

    }
}
